<?php include $this->admin_tpl('meta', 'admin');?>
<title>Tag内容管理 - YzmCMS内容管理系统</title>
	<style type="text/css">
		.table tbody tr.selected td, .table tbody tr.selected:hover td{background-color:#5b748e;color:#fff;}
		.table tbody tr.selected td a{color:#fff;}
	</style>
</head>
<body>
	<article class="page-container">
		<form action="<?php echo U(ROUTE_A);?>" method="get" id="search">
		<input type="hidden" value="<?php echo 	ROUTE_M?>" name="m">
		<input type="hidden" value="<?php echo 	ROUTE_C?>" name="c">
		<input type="hidden" value="<?php echo 	ROUTE_A?>" name="a">
		<input type="hidden" name="id" value="<?php echo $id?>" >
		<span class="select-box inline">
			<select name="modelid" class="select" onchange="change_model()">
				<?php 
					foreach($modelinfo as $val){
						$str = $val['modelid']==$modelid ? 'selected' : '';
						echo '<option value="'.$val['modelid'].'" '.$str.'>'.$val['name'].'</option>';
					}
				?>
			</select>
		</span>
		<span class="select-box inline"><?php echo select_category('catid', $catid, '不限栏目', 0, '', true, true, $modelid); ?></span>
		更新时间：<input type="text" class="input-text laydate-icon" style="width:110px;height:30px;" id="start" name="start" <?php if(isset($_GET['start']) && $_GET['start']) echo 'value="'.$_GET['start'].'"'; ?>>
     	至 <input type="text" class="input-text laydate-icon" style="width:110px;height:30px;" id="end" name="end" value="<?php if(isset($_GET['end']) &&  $_GET['end']) echo $_GET['end']; else echo date('Y-m-d'); ?>">
		<span class="select-box inline">
		<select name="type" class="select">
			<option value="1" <?php if(isset($_GET['type']) && $_GET['type']==1) echo 'selected';?>>标题</option>
			<option value="2" <?php if(isset($_GET['type']) && $_GET['type']==2) echo 'selected';?>>发布人</option>
			<option value="3" <?php if(isset($_GET['type']) && $_GET['type']==3) echo 'selected';?>>关键词</option>
			<option value="4" <?php if(isset($_GET['type']) && $_GET['type']==4) echo 'selected';?>>摘要</option>
			<option value="5" <?php if(isset($_GET['type']) && $_GET['type']==5) echo 'selected';?>>内容ID</option>
		</select>
		</span>
		<input name="searinfo" type="text" value="<?php if(isset($_GET['searinfo'])) echo $_GET['searinfo']; ?>" style="width:180px;" class="input-text" /><button name="dosubmit" class="btn btn-success btn-search" type="submit" value="1"><i class="yzm-iconfont yzm-iconsousuo"></i> 搜索</button>
		<a href="<?php echo U('content');?>" class="btn btn-primary radius"><i class="yzm-iconfont yzm-iconshuaxin"></i> 重置</a>
		</form>
		<form action="<?php echo U('content_oper');?>" method="post" id="myform" class="mb-50">
	        <table class="table table-border table-bg table-hover mt-10">
	            <thead>
	                <tr>
	                	<th width="20"><input type="checkbox"></th>
	                    <th>标题</th>
	                    <th width="100">所属栏目</th>
	                    <th width="45">点击量</th>
	                    <th width="35">状态</th>
	                    <th width="70">更新时间</th>
	                </tr>
	            </thead>
	            <tbody>
	            	<?php 
	            	foreach($data as $val){
						$is_exist = D('tag_content')->field('tagid')->where(array('modelid'=>$modelid,'aid'=>$val['id'],'tagid'=>$id))->one();
	            	?>
	                <tr <?php if($is_exist) echo 'class="selected"'; ?>>
	                	<td><input type="checkbox" value="<?php echo $val['catid']?>" name="ids[<?php echo $val['id']?>]"></td>
	                    <td>
	                    	<?php 
	                    	if($val['thumb']){
	                    		echo '<span style="color:#0a6999;font-size:14px;vertical-align:middle;" onmouseover="yzm_img_browse(this, \''.$val['thumb'].'\')" onmouseout="layer.closeAll(\'tips\')" class="yzm-iconfont yzm-icontupian1 pointer"></span>';
	                    	}
	                    	?>
                			<a href="<?php echo $val['url'];?>" target="_blank" ><?php echo $val['title'];?></a>
							<?php
							if(strpos($val['flag'], '1') !== false){
								echo '<span class="yzm-font-style" title="置顶">顶</span>';
							}
							if(strpos($val['flag'], '2') !== false){
								echo '<span class="yzm-font-style" title="头条">头</span>';
							}
							if(strpos($val['flag'], '3') !== false){
								echo '<span class="yzm-font-style" title="特荐">特</span>';
							}
							if(strpos($val['flag'], '4') !== false){
								echo '<span class="yzm-font-style" title="推荐">推</span>';
							}
							if(strpos($val['flag'], '5') !== false){
								echo '<span class="yzm-font-style" title="热点">热</span>';
							}
							if(strpos($val['flag'], '6') !== false){
								echo '<span class="yzm-font-style" title="幻灯">幻</span>';
							}
							if(strpos($val['flag'], '7') !== false){
								echo '<span class="yzm-font-style" title="跳转">跳</span>';
							}
							if($val['readpoint']){
								echo '<span class="yzm-font-style" title="付费">付</span>';
							}			
							?>	
	                    </td>
	                    <td><?php echo get_catname($val['catid']);?></td>
	                    <td><?php echo $val['click']?></td>
	                    <td><?php echo $val['status']=='0' ? '<span class="label radius">草稿</span>' : ($val['status']=='1' ? '<span class="label label-success radius">正常</span>' :'<span class="label label-danger radius">已退稿</span>');?></td>
	                    <td><span title="<?php echo '发布时间：'.date('Y-m-d H:i:s', $val['inputtime'])."\r\n更新时间：".date('Y-m-d H:i:s', $val['updatetime'])?>"><?php echo date('Y-m-d', $val['updatetime'])?></span></td>
	                </tr>
	                <?php 
	                }
	                ?>
	            </tbody>
	        </table>
	        <?php if(!$data){ ?><div class="yzm_no_data"><i class="yzm-iconfont yzm-iconshuoming"></i> 暂无数据</div><?php } ?>
	        <div id="page">
	        	<span class="page_left">共<?php echo $total?>条记录，页码：<?php echo $page->getpage()?>/<?php echo $page->total()?>
	        		<?php echo $page->page_size()?>
	        	</span>
  				<span class="page_right"><?php echo $page->gethome().$page->getlist().$page->getend().$page->getjump();?></span>
  			</div>
		    <input type="hidden" name="modelid" value="<?php echo $modelid;?>">
		    <input type="hidden" name="tagid" value="<?php echo $id;?>">
		    <input type="hidden" name="operation" value="1">
	    </form>
	    <div class="footer_btn footer_border"> 
	    	<input class="dosubmit w_100 btn-primary radius" type="button" onclick="dosub(1)" value="加入Tag">
	    	<input class="btn w_100 btn-danger radius h35" type="button" onclick="dosub(0)" value="移除Tag">
	    </div>
	</article>
	<?php include $this->admin_tpl('footer', 'admin');?>
	<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/laydate/1.1/laydate.js"></script>
	<script>
	var start = {elem:'#start',format:'YYYY-MM-DD',min:'1999-01-01',max:'2099-01-01',istime:false,istoday:false,choose:function(datas){end.min = datas;end.start = datas}
	};
	var end = {elem:'#end',format:'YYYY-MM-DD',min:'1999-01-01',max:'2099-01-01',istime:false,istoday:false,choose:function(datas){start.max = datas;}};
	laydate(start);
	laydate(end);

	function change_model() {
		$("#search").submit();
	}

	function dosub(oper){
		$("input[name='operation']").val(oper);
		$.ajax({
			type: 'POST',
			url: '<?php echo U('content_oper');?>', 
			data: $("#myform").serialize(),
			dataType: "json", 
			success: function (msg) {
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1, time:800}, function(){
						location.reload();     
					});
				}else{
					layer.msg(msg.message, {icon:2});
				}
			}
		})	
	}
	</script>
</body>

</html>